package com.tdkj.action.backstage.information;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.annotation.Resource;

import com.tdkj.action.BaseAction;
import com.tdkj.model.information.BeanInfoModule;
import com.tdkj.model.information.BeanModuleColumn;
import com.tdkj.service.information.IBeanInfoModuleService;
public class InforModuleAction  extends BaseAction{
	private long parentId;
	private long childId;
	private IBeanInfoModuleService inforModuleService;
	private String modulename;
	private BeanInfoModule inforModule;
	private BeanModuleColumn moduleColumn;
	private List<BeanInfoModule> inforModules=new ArrayList<BeanInfoModule>();
	private List<BeanModuleColumn> moduleColumns=new ArrayList<BeanModuleColumn>();
	
	public long getParentId() {
		return parentId;
	}
	public void setParentId(long parentId) {
		this.parentId = parentId;
	}
	public String getModulename() {
		return modulename;
	}
	public void setModulename(String modulename) {
		this.modulename = modulename;
	}
	public long getChildId() {
		return childId;
	}
	public void setChildId(long childId) {
		this.childId = childId;
	}
	public BeanModuleColumn getModuleColumn() {
		return moduleColumn;
	}
	public void setModuleColumn(BeanModuleColumn moduleColumn) {
		this.moduleColumn = moduleColumn;
	}
	public List<BeanModuleColumn> getModuleColumns() {
		return moduleColumns;
	}
	public void setModuleColumns(List<BeanModuleColumn> moduleColumns) {
		this.moduleColumns = moduleColumns;
	}
	
	public IBeanInfoModuleService getInforModuleService() {
		return inforModuleService;
	}
	@Resource
	public void setInforModuleService(IBeanInfoModuleService inforModuleService) {
		this.inforModuleService = inforModuleService;
	}
	public BeanInfoModule getInforModule() {
		return inforModule;
	}
	public void setInforModule(BeanInfoModule inforModule) {
		this.inforModule = inforModule;
	}
	public List<BeanInfoModule> getInforModules() {
		return inforModules;
	}
	public void setInforModules(List<BeanInfoModule> inforModules) {
		this.inforModules = inforModules;
	}
	public String findAll(){
		//initModules();
		inforModules=inforModuleService.findAll(BeanInfoModule.class);
		return "findAll";
	}
	public String  addInforModule(){
		inforModuleService.save(inforModule);
		return findAll();
	}
	public String  getAddPage(){
		return "addPage";
	}
	public String  getAddChildPage(){
		return "addChildPage";
	}
	public String  getEditPage(){
		inforModule=inforModuleService.findById(this.getParentId(), BeanInfoModule.class);
		return "editPage";
	}
	public String  getEditChildPage(){
		moduleColumn=inforModuleService.findModuleColumn(this.getChildId());
		return "editChildPage";
	}
	public String  editInforModule(){
		inforModuleService.updateModule(this.getParentId(), this.getModulename());
		return findAll();
	}
	public String  editModuleColumn(){
		BeanInfoModule module=inforModuleService.findById(this.getParentId(), BeanInfoModule.class);
		BeanModuleColumn column=this.getModuleColumn();
		column.setInforModule(module);
		inforModuleService.updateColumn(column);
		return getChildPage();
	}
	public String  deleteInforModule(){
		inforModuleService.deleteModule(this.getParentId());
		return findAll();
	}
	public String  deleteModuleColumn(){
		inforModuleService.deleteColumn(this.getChildId());
		return getChildPage();
	}
	public String getChildPage(){
		inforModule=inforModuleService.findById(this.getParentId(), BeanInfoModule.class);
		return "getChildPage";
	}
	public String  addModuleColumn(){
		inforModuleService.saveModuleColumn(this.getParentId(), moduleColumn);
		return getChildPage();
	}
}
